#include<bits/stdc++.h>
int main()
{
  int y,m,d;
  int leap=0;
  while((scanf("%d/%d/%d",&y,&m,&d))==3)
  {
    leap=0; // OMG I forgot to reset `leap'!!! CONSTANT VIGILANCE!
    if(y%4==0 && y%100!=0 || y%100==0 && y%400==0) leap=1;
    // You have to have some common knowledge to get an AC.
    switch(m)
    {
      case 12: d+=30;
      case 11: d+=31;
      case 10: d+=30;
      case 9: d+=31;
      case 8: d+=31;
      case 7: d+=30;
      case 6: d+=31;
      case 5: d+=30;
      case 4: d+=31;
      case 3: d+=(28+leap);
      case 2: d+=31; 
      default: break;
    }
    printf("%d\n",d);
  }
}
